package com.example.water.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.water.pojo.RespBean;
import com.example.water.pojo.WindBasicinfo;
import com.example.water.pojo.WindForecast;
import com.example.water.pojo.WindInfo;
import com.example.water.service.WindBasicinfoService;
import com.example.water.service.WindForecastService;
import com.example.water.service.WindInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author Shunrai
 * @create 2023/11/12 10:09
 * @Version 1.0
 * @Description
 */
@Tag(name = "台风路径")
@RestController
@RequestMapping("/Wind")
@ApiResponse(responseCode = "200",description = "查询成功")
@ApiResponse(responseCode = "404", description = "查询失败")
public class WindController {
    @Autowired
    private WindBasicinfoService windBasicinfoService;
    @Autowired
    private WindInfoService windInfoService;
    @Autowired
    private WindForecastService windForecastService;

    @Operation(summary = "得到所有的基本台风信息",description = "得到所有的基本台风信息")
    @GetMapping("/getBasic")
    private RespBean<List<WindBasicinfo>> getWindBasicInfo(){
        List<WindBasicinfo> list = windBasicinfoService.list();

        return RespBean.success("查询成功",list);
    }

    @Operation(summary = "得到台风路径信息")
    @GetMapping("/getWIfByWId")
    private RespBean<List<WindInfo>> getWindInfoByWindId(@Parameter(description = "台风编号",required = true) Integer windId){

        List<WindInfo> windInfos = windInfoService.list(new QueryWrapper<WindInfo>().eq("windid", windId));
        return RespBean.success("查询成功",windInfos);
    }

    @Operation(summary = "得到台风预测路径信息")
    @GetMapping("/getForInfo")
    private RespBean<List<WindForecast>> getWindForecastInfo(@Parameter(description = "台风编号",required = true) Integer windId){
        List<WindForecast> forecasts = windForecastService.list(new QueryWrapper<WindForecast>().eq("windid", windId));
        return RespBean.success("查询成功",forecasts);
    }

}
